﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.StubHelpers;
namespace WF01
{
    public partial class editform : Form
    {
        public editform()
        {
            InitializeComponent();
        }
        private int id;
        private string studentname;
        private int age;
        private int score;
        private object id1;
        private object name;
        private object age1;
        private object score1;

        public editform(int id, string name, int age, int score)
        {
            InitializeComponent();
            this.id = id;
            this.studentname = name;
            this.age = age;
            this.score = score;



        }

        public editform(object id1, object name, object age1, object score1)
        {
            // TODO: Complete member initialization
            this.id1 = id1;
            this.name = name;
            this.age1 = age1;
            this.score1 = score1;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();


        }

        private void button1_Click(object sender, EventArgs e)
        {

            var name = textBox1.Text;
            var age = textBox2.Text;
            var sco = textBox3.Text;

            if (this.Id > 0)
            {
                var sql = string.Format("update Students set Name='{0}',Age='{1}',Score={2} where Id={3} ", name, age, sco, this.Id);
                DBhelper.addorupdate(sql);
                MessageBox.Show("恭喜您，更新成功!");
            }
            else
            {
                var sql = string.Format("insert into Students values ('{0}',{1},{2})", name, age, sco);
                DBhelper.addorupdate(sql);
                MessageBox.Show("恭喜您，添加成功!");
            }
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }


      
public  int Id { get; set; }
internal static object showdialog()
{
    throw new NotImplementedException();
}
    }
}
